package com.infowarelab.groovytest.impl

import groovy.mock.interceptor.MockFor
import com.infowarelab.groovytest.impl.ReadServiceImpl
import com.infowarelab.groovytest.ReadService
import com.infowarelab.groovytest.ContentService

class TestReadUseProxy extends GroovyTestCase {
	void setUp(){
		println "start TestReadUseProxy"
	}

	void testRead() {
		def mock = new MockFor(ContentService)
		mock.demand.getContent(){"Kevin"}

		def contentService = mock.proxyInstance();
		def reader = new ReadServiceImpl()
		reader.setContentService(contentService)
		assertEquals reader.readContent() , "hello Kevin"
		mock.verify(contentService)
	}
}

